{% extends "base.html" %}
{% block content %}
    <div class="jumbotron">
        <h2>
            Welcome to microblog!
        </h2>
        <p>
            这是一个使用flask搭建的简单博客，适合初学者进行练手。这个博客包含了登录、发表博客、
            用户管理、登出账号、第三方登录、关注用户等功能。
        </p>
        <p>
            <a class="btn btn-primary btn-large" href="#">Learn more</a>
        </p>
    </div>
    <div class="jumbotron">
        <h2>Hi,<strong>{{ g.user.nickname }}</strong>,欢迎回来！</h2>
        {#    <form role="form">#}
        {#        <div class="form-group">#}
        {#            <label for="name">说点什么：</label>#}
        {#            <textarea class="form-control" rows="3"></textarea>#}
        {#        </div>#}
        {#    </form>#}

        <form class="form" action="" method="post" name="post">
            {{ form.hidden_tag() }}
            <div class="control-group">
                <label class="control-label" for="post">Say something:</label>
                <div class="controls">
                    {{ form.post(class='form-control',rows=5) }}
                    <p><input class="btn btn-primary" type="submit" value="发布"></p>
                    {#                    <input class="btn btn-primary" type="submit" value="发布">#}
                    {% for error in form.errors.post %}
                        <span class="help-inline">[{{ error }}]</span><br>
                    {% endfor %}
                </div>
            </div>
{#            <div class="control-group">#}
{#                <div class="controls">#}
{#                    <input class="btn btn-primary" type="submit" value="发布">#}
{#                </div>#}
{#            </div>#}
        </form>
        <hr>
        {#    <!--posts是一个分页对象>#}
        {% for post in posts.items %}
            {% include 'post.html' %}
        {% endfor %}

        <ul class="pager">
            {% if posts.has_prev %}
                <li class="previous"><a href="{{ url_for('index', page = posts.prev_num) }}">上一页</a></li>
            {% else %}
                <li class="previous disabled"><a href="#">上一页</a></li>
            {% endif %}
            {% if posts.has_next %}
                <li class="next"><a href="{{ url_for('index', page = posts.next_num) }}">下一页</a></li>
            {% else %}
                <li class="next disabled"><a href="#">下一页</a></li>
            {% endif %}
        </ul>
    </div>

{% endblock %}